Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PSDK-117] Implement Transfer Class #11

Merged
merged 4 commits into from
May 16, 2024
Merged

Conversation

John-peterson-coinbase
Copy link
Contributor

@John-peterson-coinbase John-peterson-coinbase commented May 14, 2024

What changed? Why?

  • Implement Transfer class
  • Define TransferApiClient type
  • Add TransferApiClient to ApiClients

Fast-Follow

  • ListTransfers
  • Address.transfer
  • Wallet.transfer
  • We should add invalid unsigned payload tests to both SDK's

Qualified Impact

@John-peterson-coinbase John-peterson-coinbase force-pushed the transfer-object branch 4 times, most recently from ee98266 to 20f82fe Compare May 15, 2024 22:58
@John-peterson-coinbase John-peterson-coinbase changed the title Transfer object [PSDK-117] Implement Transfer Class May 15, 2024
@John-peterson-coinbase John-peterson-coinbase marked this pull request as ready for review May 15, 2024 22:59
@@ -66,6 +66,7 @@
"text"
],
"verbose": true,
"testRegex": ".test.ts$"
"testRegex": ".test.ts$",
"maxWorkers": 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed for BigInt support in Jest

src/coinbase/transfer.ts Outdated Show resolved Hide resolved
src/coinbase/transfer.ts Outdated Show resolved Hide resolved
src/coinbase/transfer.ts Outdated Show resolved Hide resolved
src/coinbase/transfer.ts Outdated Show resolved Hide resolved
src/coinbase/transfer.ts Outdated Show resolved Hide resolved
src/coinbase/tests/transfer_test.ts Show resolved Hide resolved
src/coinbase/transfer.ts Outdated Show resolved Hide resolved
src/coinbase/transfer.ts Outdated Show resolved Hide resolved
Comment on lines 194 to 223
const startTime = Date.now();
while (Date.now() - startTime < timeoutSeconds * 1000) {
const status = await this.getStatus();
if (status === TransferStatus.COMPLETE || status === TransferStatus.FAILED) {
return this;
}
await new Promise(resolve => setTimeout(resolve, intervalSeconds * 1000));
}
throw new Error("Transfer timed out");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can create a function for this since we will use it in other classes too.

      async function delay(seconds: number) {
        return new Promise(resolve => setTimeout(resolve, seconds * 1000));
      }

Also, we may want to consider to move wait function under utils folder.

src/coinbase/coinbase.ts Show resolved Hide resolved
@John-peterson-coinbase John-peterson-coinbase merged commit e7c255d into master May 16, 2024
4 checks passed
@erdimaden erdimaden deleted the transfer-object branch June 21, 2024 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants